package controller;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import view.ApplicationView;
import view.PopUpMenu;

public class PopClickListener extends MouseAdapter {
	private ApplicationView aw;
	private ApplicationController ac;
	
	public PopClickListener(ApplicationView aw, ApplicationController ac) {
		this.aw = aw;
		this.ac = ac;
	}
	
    @Override
	public void mousePressed(MouseEvent e){
        if (e.isPopupTrigger())
            doPop(e);
    }

    @Override
	public void mouseReleased(MouseEvent e){
        if (e.isPopupTrigger())
            doPop(e);
    }

    private void doPop(MouseEvent e){
        PopUpMenu menu = new PopUpMenu(aw, ac);
        menu.show(e.getComponent(), e.getX(), e.getY());
    }
}